{% extends "shared/layout.volt" %}
{% block content %}
    <h1 class="page-header">添加支付</h1>
    <form method="post" id="addMerchantPayForm">
        <input type="hidden" name="merchant_id" value="{{ Model.merchant_id }}">
    <div class="table-responsive">
        <table class="table-tidy">
            <thead class="table-tidy-head">
            <tr>
                <th style="width: 50px;"></th>
                <th style="width: 200px;">支付名称</th>
                <th style="width: 200px;" class="text-center">支付账号</th>
                <th>支付简介</th>
                <th style="width: 120px;" class="text-center">启用状态</th>
                <th style="width: 120px;" class="text-center">状态</th>
            </tr>
            </thead>
            <tbody class="table-tidy-body" style="height: 100px;overflow: auto">
            {% for index,item in ModelList %}
                <tr>
                    <td>
                        <label class="ant-checkbox-wrapper">
                            <span class="ant-checkbox{{ item.selected ? ' ant-checkbox-checked':'' }}">
                                <span class="ant-checkbox-inner"></span>
                                <input type="checkbox" name="pay_id[{{ index }}]" class="ant-checkbox-input" value="{{ item.pay_id }}" {{ item.selected ? ' checked="checked"':'' }}>
                            </span>
                        </label>
                        {#<input type="checkbox" name="pay_id[{{ index }}]" value="{{ item.pay_id }}" {{ item.selected ? ' checked="checked"':'' }}>#}

                    </td>
                    <td>{{ item.pay_name }}</td>
                    <td>{{ item.pay_account }}</td>
                    <td>{{ item.remark }}</td>
                    <td>
                        {% if item.pay_status == 'y' %}
                            <span class="label-yes"><i class="glyphicon glyphicon-ok-circle"></i> 启用</span>
                        {% else %}
                            <span class="label-no"><i class="glyphicon glyphicon-ban-circle"></i> 停用</span>
                        {% endif %}

                    </td>
                    <td>
                        {% if item.selected %}
                            已添加
                        {% else %}
                            未添加
                        {% endif %}
                    </td>
                </tr>
            {% else %}
                <tr>
                    <td colspan="6" class="text-center">暂无记录</td>
                </tr>
            {% endfor %}
        </table>
        <div style="margin-top: 30px;">
            <button type="submit" class="btn btn-success btn-sm" id="btnSaveMerchantPay" data-loading-text="保存中..." style="padding: 5px 30px;margin-right: 20px;">确定</button>

            <button type="button" class="btn btn-default btn-sm" style="padding: 5px 30px;margin-right: 20px;" onclick=" window.location = window.document.referrer;">取消</button>
        </div>
    </div>
    </form>
{% endblock %}
{% block footer %}
<script type="text/javascript">
    $(function () {
        $("#addMerchantPayForm").on("submit",function () {

            $("#addMerchantPayForm").ajaxSubmit({
                type : "post",
                dataType : "json",
                timeout:   3000,
               // data : $("#addMerchantPayForm").serializeArray(),
                success : function ($res) {
                    if($res.errCode === 0 || $res.errCode === '0'){
                        layer.msg($res.errMsg,{time : 1000,icon :6},function () {
                           window.location = window.document.referrer;
                        });
                    }else{
                        layer.msg($res.errMsg);
                    }
                },
                error : function () {
                    layer.msg("服务器端异常");
                }
            });
            return false;
        });

    });

</script>
{% endblock %}